"""
实现背景
创建者：Carburn Ashroom
2024.1.14
"""

from PySide6.QtGui import QPixmap, QPainter

import config


class BackGround:
    """BackGround类是一个背景"""
    def __init__(self, p_dir=config.BACK_DIR, width=config.BACK_WIDTH):
        self.width = width
        self.img = QPixmap(p_dir)
        self.height = width * self.img.height() / self.img.width()

    def draw(self, dest):
        """绘制"""
        pa = QPainter(dest)
        pa.drawPixmap(0, 0, self.width, self.height, self.img)
